<template>
  <div class="common-layout">
    <div class="booking-content">
      <div class="booking-wrapper">
        <div class="booking-container">
          <h2 class="booking-title">预订会议室</h2>
          <p class="booking-subtitle">请填写以下预订信息</p>

          <form @submit.prevent="searchRooms" class="booking-form">
            <!-- 原有表单内容保持不变 -->
            <div class="form-row">
              <div class="form-field">
                <Label for-id="reservationDate">预订日期 <span class="required">*</span></Label>
                <Input
                  type="date"
                  id="reservationDate"
                  v-model="reservationDate"
                  :min="minDate"
                  :max="maxDate"
                  required
                />
              </div>
              <div class="form-field">
                <Label for-id="startTime">开始时间 <span class="required">*</span></Label>
                <select id="startTime" v-model="startTime" required>
                  <option
                    v-for="hour in availableHours"
                    :key="hour"
                    :value="`${String(hour).padStart(2, '0')}:00`"
                  >
                    {{ hour }}:00
                  </option>
                </select>
              </div>
            </div>

            <div class="form-row">
              <div class="form-field">
                <Label for-id="usageTime"
                  >预计使用时长 (小时) <span class="required">*</span></Label
                >
                <Input
                  type="number"
                  id="usageTime"
                  v-model="usageTime"
                  min="1"
                  placeholder="例如：2"
                  required
                />
              </div>
              <div class="form-field">
                <Label for-id="attendees">预计参会人数 <span class="required">*</span></Label>
                <Input
                  type="number"
                  id="attendees"
                  v-model="attendees"
                  min="1"
                  placeholder="例如：10"
                  required
                />
              </div>
            </div>

            <div class="equipment-section">
              <Label>所需设备</Label>
              <Button type="button" @click="toggleAllEquipment">
                {{ allSelected ? '取消全选' : '全选所有设备' }}
              </Button>
              <div class="equipment-grid">
                <div class="equipment-item">
                  <input
                    type="checkbox"
                    id="projector"
                    v-model="selectedEquipment"
                    value="投影仪"
                  />
                  <Label for-id="projector">投影仪</Label>
                </div>
                <div class="equipment-item">
                  <input type="checkbox" id="audio" v-model="selectedEquipment" value="音响系统" />
                  <Label for-id="audio">音响系统</Label>
                </div>
                <div class="equipment-item">
                  <input type="checkbox" id="network" v-model="selectedEquipment" value="网络" />
                  <Label for-id="network">网络</Label>
                </div>
              </div>
            </div>

            <Button type="submit" class="search-button"> 搜索可用会议室 </Button>
          </form>
        </div>
      </div>

      <div v-if="availableRooms.length > 0" class="rooms-container">
        <h3 class="rooms-title">可用会议室</h3>
        <div class="rooms-grid">
          <div v-for="room in availableRooms" :key="room.id" class="room-card">
            <!-- 原有会议室卡片内容保持不变 -->
            <div class="room-header">
              <h4 class="room-name">{{ room.name }}</h4>
              <p class="room-type">{{ room.type === 'CLASSROOM_STYLE' ? '教室型' : '圆桌型' }}</p>
              <!--              <span class="status-badge" :class="getStatusClass(room.status)">
                {{ room.status }}
              </span>-->
            </div>

            <div class="room-details">
              <p><span class="detail-label">容量：</span>{{ room.seats }}人</p>
              <p><span class="detail-label">面积：</span>{{ room.areaSqm }}㎡</p>
              <p><span class="detail-label">价格：</span>¥{{ room.pricePerHour }}/小时</p>
            </div>

            <div class="room-equipment">
              <p class="equipment-label">设备配置：</p>
              <div class="equipment-tags">
                <span v-for="eq in room.equipment" :key="eq" class="equipment-tag">
                  {{ eq }}
                </span>
              </div>
            </div>

            <Button @click="selectRoom(room)" class="book-button"> 选择并预订 </Button>
          </div>
        </div>
      </div>
      <div v-else class="bg-white shadow rounded-lg p-6 text-center text-gray-500">
        <p>没有找到符合您条件的可用会议室。</p>
      </div>

      <!-- 倒计时弹窗 -->
      <div v-if="showPaymentDialog" class="payment-dialog-overlay">
        <div class="payment-dialog">
          <h3 class="payment-title">订单支付</h3>

          <div class="payment-content">
            <p class="payment-tip">请在30分钟内完成支付，否则订单将自动取消</p>
            <div class="time-remaining">
              <span>剩余支付时间：</span>
              <span :class="getTimeRemainingClass(paymentTimer)">
                {{ Math.floor(paymentTimer / 60) }}分{{ paymentTimer % 60 }}秒
              </span>
            </div>
          </div>

          <div class="payment-buttons">
            <Button @click="handleCancelPayment" class="payment-button cancel-button">
              再想想
            </Button>
            <Button @click="handlePayment" class="payment-button pay-button"> 支付 </Button>
            <Button @click="handleLaterPayment" class="payment-button later-button">
              稍后支付
            </Button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onUnmounted } from 'vue'
import axios from 'axios'
import { useAuthStore } from '@/stores/auth'
import { ElMessage } from 'element-plus'
import { ElMessageBox } from 'element-plus'
import { useReservationStore } from '@/stores/reservation'

// Import custom UI components
// import Button from '../../components/ui/Button.vue';
import Input from '../../components/ui/Input.vue'
import Label from '../../components/ui/Label.vue'
// Select is not directly used in BookRoomView's form, but might be useful later.
// import Select from '../../components/ui/Select.vue';

const today = new Date()
const minDate = ref(today.toISOString().split('T')[0])
const maxDate = ref(
  new Date(today.getTime() + 60 * 24 * 60 * 60 * 1000).toISOString().split('T')[0]
)
const reservationDate = ref('')

const startTime = ref('08:00')

const usageTime = ref(1)
const availableHours = ref([...Array(14).keys()].map((i) => i + 8)) // 8-21
const attendees = ref(1)
const selectedEquipment = ref([])
const availableRooms = ref([])
const allSelected = ref(false)
const paymentTimer = ref(0)
const timerInterval = ref(null)
const showPaymentDialog = ref(false)
const currentReservationId = ref(null)
const selectedRoom = ref(null)

const reservationStore = useReservationStore()

const searchRooms = async () => {
  if (!reservationDate.value) {
    ElMessage.warning('请选择预订日期。')
    return
  }
  if (!startTime.value) {
    ElMessage.warning('请选择开始时间。')
    return
  }

  const selectedHour = parseInt(startTime.value.split(':')[0])
  if (selectedHour < 8 || selectedHour > 21) {
    ElMessage.warning('会议室可使用时间为8:00-21:00')
    availableRooms.value = []
    return
  }

  // 验证预订日期和时间是否晚于当前时间
  const selectedDateTime = new Date(`${reservationDate.value}T${startTime.value}:00`)
  const currentDateTime = new Date()

  // 如果是今天的预订，检查是否晚于当前时间
  if (reservationDate.value === minDate.value && selectedDateTime <= currentDateTime) {
    ElMessage.warning('预订时间不能早于当前时间')
    availableRooms.value = []
    return
  }

  // 验证结束时间是否在8:00-21:00之间
  const endHour = selectedHour + parseInt(usageTime.value)
  if (endHour > 21) {
    ElMessage.warning(`预订时长超出当天可用时间，最晚可预订到21:00`)
    availableRooms.value = []
    return
  }

  try {
    // Format start time as "YYYY-MM-DDTHH:mm:ss"
    const startDate = new Date(`${reservationDate.value}T${startTime.value}:00`)
    console.log(reservationDate.value, startTime.value)

    const searchStartTime = `${startDate.getFullYear()}-${String(startDate.getMonth() + 1).padStart(
      2,
      '0'
    )}-${String(startDate.getDate()).padStart(2, '0')}T${String(startDate.getHours()).padStart(
      2,
      '0'
    )}:${String(startDate.getMinutes()).padStart(2, '0')}:${String(startDate.getSeconds()).padStart(
      2,
      '0'
    )}`

    // Format end time as "YYYY-MM-DDTHH:mm:ss"
    const endDate = new Date(startDate.getTime() + usageTime.value * 60 * 60 * 1000)
    const searchEndTime = `${endDate.getFullYear()}-${String(endDate.getMonth() + 1).padStart(
      2,
      '0'
    )}-${String(endDate.getDate()).padStart(2, '0')}T${String(endDate.getHours()).padStart(
      2,
      '0'
    )}:${String(endDate.getMinutes()).padStart(2, '0')}:${String(endDate.getSeconds()).padStart(
      2,
      '0'
    )}`

    const response = await axios.get('http://localhost:8080/api/meetingrooms/available', {
      params: {
        startTime: searchStartTime,
        endTime: searchEndTime,
        attendees: attendees.value,
        hasProjector: selectedEquipment.value.includes('投影仪'),
        hasSoundSystem: selectedEquipment.value.includes('音响系统'),
        hasNetwork: selectedEquipment.value.includes('网络'),
      },
    })
    availableRooms.value = response.data.map((room) => ({
      ...room,
      equipment: [
        ...(room.hasProjector ? ['投影仪'] : []),
        ...(room.hasSoundSystem ? ['音响系统'] : []),
        ...(room.hasNetwork ? ['网络'] : []),
        ...(room.otherEquipmentDetails
          ? room.otherEquipmentDetails.split(',').map((item) => item.trim())
          : []),
      ],
    }))
    console.log('Available rooms:', availableRooms.value)
  } catch (error) {
    console.error('Error searching for rooms:', error)
    ElMessage.error(error.response?.data?.message || '搜索会议室时发生错误。')
  }
}

const selectRoom = async (room) => {
  const authStore = useAuthStore()
  const userId = authStore.user?.userId

  if (!userId) {
    console.error('User not authenticated.')
    ElMessage.error('用户未认证。请登录。')
    return
  }

  try {
    // Format start time as "YYYY-MM-DDTHH:mm:ss"
    const startDate = new Date(`${reservationDate.value}T${startTime.value}:00`)
    const reservationStartTime = `${startDate.getFullYear()}-${String(
      startDate.getMonth() + 1
    ).padStart(2, '0')}-${String(startDate.getDate()).padStart(2, '0')}T${String(
      startDate.getHours()
    ).padStart(2, '0')}:${String(startDate.getMinutes()).padStart(2, '0')}:${String(
      startDate.getSeconds()
    ).padStart(2, '0')}`

    // Format end time as "YYYY-MM-DDTHH:mm:ss"
    const endDate = new Date(startDate.getTime() + usageTime.value * 60 * 60 * 1000)
    const reservationEndTime = `${endDate.getFullYear()}-${String(endDate.getMonth() + 1).padStart(
      2,
      '0'
    )}-${String(endDate.getDate()).padStart(2, '0')}T${String(endDate.getHours()).padStart(
      2,
      '0'
    )}:${String(endDate.getMinutes()).padStart(2, '0')}:${String(endDate.getSeconds()).padStart(
      2,
      '0'
    )}`

    const response = await axios.post('http://localhost:8080/api/reservations', {
      userId: userId,
      roomId: room.roomId,
      startTime: reservationStartTime,
      endTime: reservationEndTime,
      participants: attendees.value,
      equipmentRequiredNotes: selectedEquipment.value.join(', '),
      totalPrice: usageTime.value * room.pricePerHour,
    })

    if (response.data && response.data.bookingId) {
      ElMessage.success({
        message: '预订订单已成功生成！请在30分钟内完成支付。',
        duration: 1000,
      })

      reservationStore.setNeedRefresh(true)

      // 保存订单ID和会议室信息并显示弹窗
      currentReservationId.value = response.data.bookingId
      selectedRoom.value = room
      console.log('Current reservation ID:', currentReservationId.value)

      showPaymentDialog.value = true
      paymentTimer.value = 30 * 60

      if (timerInterval.value) clearInterval(timerInterval.value)
      timerInterval.value = setInterval(() => {
        paymentTimer.value--
        if (paymentTimer.value <= 0) {
          clearInterval(timerInterval.value)
          handlePaymentTimeout()
        }
      }, 1000)

      // 添加这行：重新搜索可用会议室
      await searchRooms()
    } else {
      ElMessage.error('生成预订订单失败：未收到有效订单ID')
    }
  } catch (error) {
    console.error('Error selecting room and generating order:', error)
    ElMessage.error(error.response?.data?.message || '生成订单时发生错误。')
  }
}

const toggleAllEquipment = () => {
  allSelected.value = !allSelected.value
  if (allSelected.value) {
    selectedEquipment.value = ['投影仪', '音响系统', '网络']
  } else {
    selectedEquipment.value = []
  }
}

// Clear timer when component unmounts
// 支付超时处理
const handlePaymentTimeout = async () => {
  try {
    await axios.put(`http://localhost:8080/api/reservations/${currentReservationId.value}/cancel`, {
      reason: '支付超时',
    })
    ElMessage.warning('支付超时，预订已取消')
    showPaymentDialog.value = false
  } catch (error) {
    console.error('取消订单失败:', error)
    ElMessage.error('取消订单时发生错误')
  }
}

// 立即支付
const handlePayment = async () => {
  showPaymentDialog.value = false

  try {
    const result = await ElMessageBox.confirm(
      `<div class="payment-confirm-content">
        <div class="confirm-title">确认支付会议室预订</div>
        <div class="confirm-detail">
          <div><span class="detail-label">会议室：</span>${selectedRoom.value?.name || ''}</div>
          <div><span class="detail-label">预订时长：</span>${usageTime.value}小时</div>
          <div><span class="detail-label">支付金额：</span>¥${(
            usageTime.value * selectedRoom.value?.pricePerHour || 0
          ).toFixed(2)}</div>
        </div>
      </div>`,
      '确认支付',
      {
        confirmButtonText: '立即支付',
        cancelButtonText: '稍后支付',
        type: 'warning',
        dangerouslyUseHTMLString: true,
        customClass: 'payment-confirm-dialog',
        width: '500px',
      }
    )

    if (result === 'confirm') {
      // 支付处理
      await axios.put(
        `http://localhost:8080/api/reservations/confirm-reservation/${currentReservationId.value}`
      )
      clearInterval(timerInterval.value)
      ElMessage.success('订单已确认！')

      // 通知订单状态更新
      reservationStore.setNeedRefresh(true)

      // 清理当前订单状态
      currentReservationId.value = null
      showPaymentDialog.value = false
    }
  } catch (error) {
    if (error !== 'cancel') {
      console.error('确认订单失败:', error)
      ElMessage.error(error.response?.data?.message || '确认订单时发生错误')
    }
  }
}

// 稍后支付
const handleLaterPayment = () => {
  showPaymentDialog.value = false
  ElMessage.info('您可以稍后在"我的订单"中完成支付')
}

// 删除订单
const handleCancelPayment = async () => {
  if (!currentReservationId.value) {
    ElMessage.warning('没有可取消的订单')
    return
  }

  try {
    await axios.delete(`http://localhost:8080/api/reservations/${currentReservationId.value}`)
    ElMessage.success('订单已取消')
    showPaymentDialog.value = false
    clearInterval(timerInterval.value)
    currentReservationId.value = null

    // 通知其他组件刷新订单列表
    reservationStore.setNeedRefresh(true)
    //刷新可用会议室列表
    await searchRooms()
  } catch (error) {
    console.error('取消订单失败:', error)
    ElMessage.error(error.response?.data?.message || '取消订单时发生错误')
  }
}

onUnmounted(() => {
  if (timerInterval.value) {
    clearInterval(timerInterval.value)
    timerInterval.value = null
  }
})

const getStatusClass = (status) => {
  switch (status) {
    case '正常':
    case '空闲':
      return 'status-available'
    case '锁定':
      return 'status-locked'
    case '预定':
      return 'status-reserved'
    case '使用':
      return 'status-in-use'
    case '维护':
      return 'status-maintenance'
    default:
      return 'status-default'
  }
}

const getTimeRemainingClass = (seconds) => {
  if (seconds > 600) return 'time-remaining-green'
  if (seconds > 300) return 'time-remaining-yellow'
  return 'time-remaining-red'
}
</script>

<style scoped>
.booking-content {
  padding: 40px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 60px);
}

.booking-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  background-color: #fff;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.booking-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.booking-card {
  width: 100%;
  max-width: 1200px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  padding: 40px;
  margin: 20px 0;
}

/* 会议室卡片样式 */
.rooms-container {
  margin-top: 30px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.rooms-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 20px;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.room-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.room-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.room-header {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #f0f0f0;
}

.room-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.room-type {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin-bottom: 10px;
}

.room-details {
  margin-bottom: 15px;
}

.detail-label {
  font-weight: 500;
  color: #34495e;
}

.room-equipment {
  margin-bottom: 20px;
  flex: 1; /* 让设备部分自适应占据剩余空间 */
}

.equipment-label {
  font-weight: 500;
  color: #34495e;
  margin-bottom: 8px;
}

.equipment-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  height: 4.5em; /* 固定高度为3行 */
  overflow: hidden;
}

.equipment-tag {
  background-color: #f0f4f8;
  color: #4a5568;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-available {
  background-color: #e6fffa;
  color: #38b2ac;
}

.status-locked {
  background-color: #fffaf0;
  color: #dd6b20;
}

.status-reserved {
  background-color: #ebf8ff;
  color: #3182ce;
}

.status-in-use {
  background-color: #faf5ff;
  color: #805ad5;
}

.status-maintenance {
  background-color: #fff5f5;
  color: #e53e3e;
}

.status-default {
  background-color: #f7fafc;
  color: #4a5568;
}

.book-button {
  width: 100%;
  padding: 10px;
  background-color: #38b2ac;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-top: auto; /* 将按钮推到底部 */
}

.book-button:hover {
  background-color: #319795;
}

/* 表单样式 */
.booking-title {
  font-size: 2rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 1rem;
  text-align: center;
}

.booking-subtitle {
  font-size: 1.1rem;
  color: #7f8c8d;
  margin-bottom: 2rem;
  text-align: center;
}

.booking-form {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.form-field {
  flex: 1;
}

.form-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #2c3e50;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.2s;
}

/* 日期选择器样式 */
.form-field input[type='date'] {
  /* 恢复原生样式 */
  padding: 10px 12px;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: #38b2ac;
  box-shadow: 0 0 0 3px rgba(56, 178, 172, 0.2);
}

.required {
  color: #e53e3e;
}

.equipment-section {
  background-color: #f8fafc;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.equipment-section label {
  display: block;
  margin-bottom: 12px;
  font-weight: 500;
  color: #2c3e50;
}

.equipment-section button {
  width: auto;
  padding: 6px 12px;
  margin-bottom: 15px;
  background-color: #38b2ac;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s;
}

.equipment-section button:hover {
  background-color: #319795;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.equipment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background-color: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.equipment-item input[type='checkbox'] {
  width: 18px;
  height: 18px;
}

.search-button {
  width: 100%;
  padding: 12px;
  background-color: #38b2ac;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s;
}

.search-button:hover {
  background-color: #319795;
}

/* 支付弹窗样式 - 精致版 */
.payment-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0);
  }

  to {
    opacity: 1;
    backdrop-filter: blur(3px);
  }
}

.payment-dialog {
  background-color: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  padding: 36px;
  width: 100%;
  max-width: 440px;
  transform: translateY(0);
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  border: none;
  position: relative;
  overflow: hidden;
}

.payment-dialog::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #38b2ac, #3498db);
}

.payment-title {
  font-size: 24px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 24px;
  text-align: center;
  position: relative;
  padding-bottom: 16px;
  letter-spacing: 0.5px;
}

.payment-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 30%;
  width: 40%;
  height: 3px;
  background: linear-gradient(to right, transparent, #38b2ac, transparent);
  border-radius: 3px;
}

.payment-content {
  margin-bottom: 32px;
  padding: 0 12px;
}

.payment-tip {
  font-size: 16px;
  color: #5a6a7e;
  margin-bottom: 20px;
  text-align: center;
  line-height: 1.6;
}

.time-remaining {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 17px;
  color: #3d4e60;
  padding: 16px 20px;
  background-color: #f8fafc;
  border-radius: 10px;
  margin-top: 20px;
  border: 1px solid #e2e8f0;
}

.time-remaining span:last-child {
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.5px;
}

.time-remaining-green {
  color: #27ae60;
}

.time-remaining-yellow {
  color: #f39c12;
}

.time-remaining-red {
  color: #e74c3c;
}

.payment-buttons {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-top: 24px;
  justify-content: space-between;
}

.payment-button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 17px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.payment-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.payment-button:hover::after {
  transform: translateX(0);
}

.payment-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.payment-button:active {
  transform: translateY(0);
}

.pay-button {
  background-color: #27ae60;
  color: white;
}

.pay-button:hover {
  background-color: #219653;
}

.later-button {
  background-color: #3498db;
  color: white;
}

.later-button:hover {
  background-color: #2980b9;
}

.cancel-button {
  background-color: #e74c3c;
  color: white;
}

.cancel-button:hover {
  background-color: #c0392b;
}
</style>
